<template>
  <view class="container">
    <!-- 顶部组件 -->
    <u-navbar
      :is-back="true"
      :background="{ background: '#fff' }"
      border-bottom
      id="nav-bar"
      title="选择自提门店"
    ></u-navbar>
    <view class="address-list">
      <view
        class="address-item"
        v-for="item in siteList"
        :key="item.id"
        @click="handleChoose(item)"
      >
        <image
          class="addressIcon"
          src="/static/images/icon-ztmd.png"
          mode="scaleToFill"
        />
        <view class="center">
          <view class="item-top">
            <view class="name">{{ item.name }}</view>
          </view>
          <view class="item-bottom">
            {{ item.address }}
          </view>
        </view>
        <!-- <text class="distance">1.5km</text> -->
      </view>
    </view>
  </view>
</template>
<script>
import service from '@/common/service.js';
import { showLoading, hideLoading } from '@/common/utils.js';

export default {
  data() {
    return {
      siteList: [
        {
          id: 1,
          name: '北京世纪佳缘',
          address: '北京市海淀区西二旗',
          distance: '1.5km',
        },
        {
          id: 2,
          name: '北京世纪佳缘',
          address: '北京市海淀区西二旗',
          distance: '1.5km',
        },
      ],
      tradeNo: null,
    };
  },
  onLoad(e) {
    if (e.tradeNo) {
      this.tradeNo = e.tradeNo;
    }
    this.getData();
  },
  methods: {
    getData() {
      const that = this;
      const params = {};
    //   showLoading();
      //   service.getWareHouseList(
      //     params,
      //     function (res) {
      //       hideLoading();
      //       that.siteList = res;
      //     },
      //     function (res) {
      //       hideLoading();
      //     }
      //   );
    },
    handleChoose(data) {
      uni.$emit('storeData', { storeInfo: data });
      if (this.tradeNo) {
        uni.$emit('tradeNo', { tradeNo: this.tradeNo });
      }
      uni.navigateBack({
        delta: 1,
      });
    },
  },
};
</script>

<style lang="scss">
page {
  background-color: #f7f7f7;
}

.container {
  width: 100%;
  min-height: 100vh;
  padding: 30rpx;
  text-align: center;
  background-color: #f7f7f7;
}

.address-list {
  width: 100%;

  .address-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30rpx;
    width: 100%;
    padding: 40rpx 20rpx;
    background-color: #ffffff;
    border-radius: 10rpx;
    .addressIcon {
      width: 26rpx;
      height: 32rpx;
    }
    .center {
      flex: 1;
      padding: 0 20rpx;
      .item-top {
        display: flex;
        font-weight: bold;
        font-size: 34rpx;
        .label {
          margin-right: 20rpx;
          width: 60rpx;
          height: 34rpx;
          line-height: 34rpx;
          color: #cc921f;
          font-size: 20rpx;
          border-radius: 6rpx;
          text-align: center;
          background-color: #fff7e5;
        }
        .name {
          font-size: 28rpx;
          color: #2f2f2f;
        }
        .phone {
          margin-left: 20rpx;
          font-size: 26rpx;
          color: #2f2f2f;
        }
        .tag {
          display: flex;
          font-weight: normal;
          align-items: center;
          text {
            display: block;
            width: 60rpx;
            height: 34rpx;
            line-height: 34rpx;
            color: #ffffff;
            font-size: 20rpx;
            border-radius: 6rpx;
            text-align: center;
            margin-left: 30rpx;
            background-color: rgb(49, 145, 253);
          }
          .red {
            background-color: #ff4019;
          }
        }
      }
      .item-bottom {
        display: flex;
        margin-top: 15rpx;
        font-size: 24rpx;
        justify-content: space-between;
        color: #999999;
        text-align: left;
      }
    }
    .distance {
      font-size: 24rpx;
      font-family: PingFang SC, sans-serif;
      font-weight: normal;
      color: #2f2f2f;
      line-height: 1;
    }
  }
}

.bottom {
  position: fixed;
  left: 0;
  bottom: 40rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 30rpx;
  .bottom-btn {
    width: 100%;
    height: 88rpx;
    line-height: 88rpx;
    font-size: 28rpx;
    font-weight: bold;
    color: #ffffff;
    background: linear-gradient(90deg, #22242e, #434759);
    border-radius: 10rpx;
  }
}
</style>
